/**
*
* @author Anastasiya
*
*/

#include "arguments.h"
#include "procinp.h"

using namespace ogdf;
using namespace std;

void failure(const string message, args::Arguments* parsedArguments);
void exit(const string message, args::Arguments* parsedArguments);

int main(int argc, char* argv[]){

	args::Arguments* programArguments = NULL;
	try{
		programArguments = args::parseArgs(argc, argv);
		InputProcessor inputProcessor(programArguments->inputPath, programArguments->testMode);
		inputProcessor.process();
	}catch (string ex){
		failure(ex, programArguments);
	}catch (int){
		failure("unknown error", programArguments);
	}

	exit("Exiting...", programArguments);
}

void failure(const string message, args::Arguments* parsedArguments){
	if(parsedArguments != NULL){
		delete parsedArguments;
	}
	cout << "Program failed: " << message << endl;
	std::exit(EXIT_FAILURE);
}

void exit(const string message, args::Arguments* parsedArguments){
	if(parsedArguments != NULL){
		delete parsedArguments;
	}
	cout << message << endl;
	std::exit(EXIT_SUCCESS);
}


